import type {baseResponse, listResponse, paramsType} from "@/api/index";
import {useAxios} from "@/api/index";

export interface imageType {
    "id": number
    "createdAt": string
    "userID": number
    "filename": string
    "filePath": string
    "hash": string
    "size": number
    "userNickname": string
    "userAvatar": string
    "webPath": string
}

export function imageListApi(params: paramsType):Promise<baseResponse<listResponse<imageType>>>{
    return  useAxios.get("/api/image", {params})
}

export function imageUploadApi(file: File):Promise<baseResponse<string>>{
    const form = new FormData()
    form.append("file", file)
    return useAxios.post("/api/image", form, {
        headers: {
            'Content-Type': 'multipart/form-data;charset=UTF-8'
        }
    })
}